﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<link type="text/css" rel="stylesheet" href="css/layout.css" />
<title>Danh sách thông báo</title>
<script src="../js/ajaxfilemanager/jscripts/tiny_mce/tiny_mce.js" language="javascript" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
		tinyMCE.init({
				mode : "textareas",
				elements : "ajaxfilemanager",
				theme : "advanced",
				plugins : "table,advhr,advimage,advlink,flash,paste,fullscreen,noneditable,contextmenu",
				theme_advanced_buttons1_add_before : "newdocument,separator",
				theme_advanced_buttons1_add : "fontselect,fontsizeselect",
				theme_advanced_buttons2_add : "separator,forecolor,backcolor,liststyle",
				theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,",
				theme_advanced_buttons3_add_before : "tablecontrols,separator",
				theme_advanced_buttons3_add : "flash,advhr,separator,fullscreen",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				extended_valid_elements : "hr[class|width|size|noshade]",
				file_browser_callback : "ajaxfilemanager",
				paste_use_dialog : false,
				theme_advanced_resizing : true,
				theme_advanced_resize_horizontal : true,
				apply_source_formatting : true,
				force_br_newlines : true,
				force_p_newlines : false,	
				relative_urls : true
			});
	
			function ajaxfilemanager(field_name, url, type, win) {
				var ajaxfilemanagerurl = "../../../../jscripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";
				switch (type) {
					case "image":
						break;
					case "media":
						break;
					case "flash": 
						break;
					case "file":
						break;
					default:
						return false;
				}
				var fileBrowserWindow = new Array();
				fileBrowserWindow["file"] = ajaxfilemanagerurl;
				fileBrowserWindow["title"] = "Ajax File Manager";
				fileBrowserWindow["width"] = "782";
				fileBrowserWindow["height"] = "440";
				fileBrowserWindow["close_previous"] = "no";
				tinyMCE.openWindow(fileBrowserWindow, {
				  window : win,
				  input : field_name,
				  resizable : "yes",
				  inline : "yes",
				  editor_id : tinyMCE.getWindowArg("editor_id")
				});
				
				return false;
			}
	</script>
		<script language="javascript" src="../js/jquery.js" type="text/javascript"></script>
	<script language="javascript" src="../js/ui.datepicker.js" type="text/javascript"></script>
	<link href="../css/ui.datepicker.css" type="text/css" rel="stylesheet" />
	<script language="javascript">
		jQuery("document").ready(function(){
			jQuery( "#createtime" ).datepicker();
		});
	</script>
 </head>
<body>
<?php include("menu.php"); 
include("../include/config.php");
?>
<?php
	if(isset($_REQUEST['edit_notification']))
	{
		$num = $_REQUEST['num'];
		$title=$_REQUEST['title'];
		$status=$_REQUEST['status_id'];
		$description=$_REQUEST['description'];
			
		$createtime = $_REQUEST["createtime"];
		$createtime = explode("-", $createtime);
		$createtime = $createtime[2].'-'.$createtime[1].'-'.$createtime[0];
		$sql="UPDATE notification SET title = '$title',status = '$status',description = '$description',date = '$createtime' WHERE id = $num ";
		$rs=mysql_query($sql);
		if($rs)
			{ echo ("Sửa Thành Công");
			}
		else { echo ("Truy vấn sai");
			}			
	}
	if(isset($_REQUEST['id']))
	{
		$id = $_REQUEST['id'];
		$sql = "SELECT * FROM notification WHERE id = $id";
		$rs = mysql_query($sql);
		if($rs)
		{
		$rw = mysql_fetch_array($rs);
?>

<div id="head-noidung">
	<div id="head-main">
		<h2> Sửa thông báo </h2>
	<form action = "?num=<?php echo $rw['id'];?>" name="product" method="post"  enctype="multipart/form-data">
	<table class="classtable">
	<tbody>
	<tr>
	<td>Tiêu đề</td>
	<td><input name="title" type="text" style="float:left; margin-left:10px;" value="<?php echo $rw['title'];?>"></td>
	</tr>
	<tr>
		<td>Ngày đăng</td>
		<td>
			<input type="text" name="createtime" id="createtime" style = "float:left;margin-left:10px;" value="<?php echo $rw['date']; ?>" />
		</td>
	</tr>
	
	<tr>
	<td>Mô tả</td>
	<td><textarea name="description" style="width:650px; height:300px;" value="<?php echo $rw['description'];?>" ></textarea></td>
	</tr>		
	<tr>
	<td>Trạng thái</td>
	<td>		
	<select name="status_id" style = "float:left;margin-left:10px;">
		<option value = "1" <?php if($rw['status'] == 1) echo "selected"; ?>> Đăng Tin </option>
		<option value = "2" <?php if($rw['status'] == 2) echo "selected"; ?>> Lưu Trữ </option>
		<option value = "0" <?php if($rw['status'] == 0) echo "selected"; ?>> Hết Hiệu Lực </option>
	<select>	
	</tr>	
	<tr>
	<td></td>
	<td><input type="submit" name="edit_notification" value=" Sửa thông báo " /></td>
	</tr>
	
	</tbody>
	</table>
	</form>
	</div>	
</div>


<?php 
		} 
	} 
include("images/cherry/footer.php");?>

</body>
</html>